local ma__jijian = fk.CreateSkill{
  name = "ma__jijian"
}

Fk:loadTranslationTable{
  ["ma__jijian"] = "忌剑",
  [":ma__jijian"] = "出牌阶段限一次，你可以视为对一名其他角色使用【决斗】并选择一项：<br>"..
    "1.令其重铸手牌中所有【杀】；2.令其重铸所有非【杀】手牌，此【决斗】伤害+1。",

  ["#ma__jijian"] = "忌剑：你可以视为对一名其他角色使用【决斗】，并令其重铸【杀】或非【杀】手牌",
  ["ma__jijian-choose1"] = "令其重铸手牌中所有【杀】",
  ["ma__jijian-choose2"] = "令其重铸所有非【杀】手牌，此【决斗】伤害+1",

  ["$ma__jijian1"] = "",
  ["$ma__jijian2"] = "",
}

ma__jijian:addEffect("active", {
  anim_type = "offensive",
  prompt = "#ma__jijian",
  card_num = 0,
  target_num = 1,
  can_use = function(self, player)
    return player:usedSkillTimes(ma__jijian.name, Player.HistoryPhase) == 0
  end,
  card_filter = Util.FalseFunc,
  target_filter = function(self, player, to_select, selected)
    return #selected == 0 and to_select ~= player
  end,
  on_use = function(self, room, effect)
    local player = effect.from
    local target = effect.tos[1]
    room:useVirtualCard("duel", nil, player, target, ma__jijian.name)
  end,
})

ma__jijian:addEffect(fk.TargetSpecified, {
  mute = true,
  can_trigger = function(self, event, target, player, data)
    if target == player and player:hasSkill(ma__jijian.name) and
      table.contains(data.card.skillNames, ma__jijian.name) then
      if data.firstTarget then
        return true
      end
    end
  end,
  on_cost = function(self, event, target, player, data)
    local room = player.room
    local choice = room:askToChoice(player, {
      choices = {"ma__jijian-choose1", "ma__jijian-choose2"},
      skill_name = ma__jijian.name,
    })
    event:setCostData(self, {tos = {data.to}, choice = choice})
    return true
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local choice = event:getCostData(self).choice
      if choice == "ma__jijian-choose1" then
        local cards = table.filter(data.to:getCardIds("h"), function (id)
        return Fk:getCardById(id).trueName == "slash"
        end) if #cards > 0 then
        room:recastCard(cards, data.to, ma__jijian.name)
        end
      else local cards = table.filter(data.to:getCardIds("h"), function (id)
        return Fk:getCardById(id).trueName ~= "slash"
        end) if #cards > 0 then
        room:recastCard(cards, data.to, ma__jijian.name)
        end
      data.additionalDamage = (data.additionalDamage or 0) + 1
      end
  end
})

return ma__jijian
